package com.su.servlet;

import com.su.bean.User;
import com.su.service.UserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet(name = "userInfoServlet", value = "/userInfoServlet")
public class userInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService userService = new UserService();
        List<User> userInfo = null;
        try {
            userInfo = userService.getUserInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (User user : userInfo) {
            System.out.println(user);
        }
        request.setAttribute("msg", userInfo);

        request.getRequestDispatcher("/userInfoPanel.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
